#include "StaminaLackDialog.h"
#include "../../../model/proxy/UserProxy.h"
#include "../item/Item.h"

StaminaLackDialog::StaminaLackDialog(void)
	:mPower(NULL),mCost(NULL)
{
}

StaminaLackDialog::~StaminaLackDialog(void)
{
	CC_SAFE_RELEASE(mPower);
	CC_SAFE_RELEASE(mCost);
}

bool StaminaLackDialog::init()
{
	return true;
}

SEL_MenuHandler StaminaLackDialog::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName )
{
	CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onDoItClick", StaminaLackDialog::onDoItClick);
	return NULL;
}

SEL_CCControlHandler StaminaLackDialog::onResolveCCBCCControlSelector( CCObject * pTarget, CCString * pSelectorName )
{
	CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onBuyOrUserBtnClick", StaminaLackDialog::onBuyOrUserBtnClick);
	CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCloseBtnClick", StaminaLackDialog::onCloseBtnClick);
	return NULL;
}

bool StaminaLackDialog::onAssignCCBMemberVariable( CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode )
{
	CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mPower", CCLabelTTF *, this->mPower);
	CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mCost", CCLabelTTF *, this->mCost);
	return false;
}

void StaminaLackDialog::onNodeLoaded( CCNode * pNode, CCNodeLoader * pNodeLoader )
{

}

void StaminaLackDialog::onEnter()
{
	ModelDialog::onEnter();
}

void StaminaLackDialog::onExit()
{
	ModelDialog::onExit();
}

void StaminaLackDialog::refresh()
{
	UserVO& userVO = UserProxy::getSingletonPtr()->userVO;
	mPower->setString(fcs("%d/%d", userVO.powerCur, userVO.powerMax));
	Item* itemIcon = new Item();
	itemIcon->itemID = 90001;
	itemIcon->setIcon();
	addChild(itemIcon);
}

void StaminaLackDialog::_onNotification( CCObject* object )
{
	
}

void StaminaLackDialog::onDoItClick(CCObject* pSender)
{
    
}

void StaminaLackDialog::onBuyOrUserBtnClick( CCObject * pSender, CCControlEvent pCCControlEvent )
{
	close();
}

void StaminaLackDialog::onCloseBtnClick( CCObject * pSender, CCControlEvent pCCControlEvent )
{
	close();
}
